//
//  WordsView.h
//  KidReading
//
//  Created by telen on 15/1/4.
//  Copyright (c) 2015年 刘赞黄Telen. All rights reserved.
//

#import <UIKit/UIKit.h>

#import "StatusButtonView.h"
#import "WordsDictData.h"
#import "TLMutexUIViewDelegate.h"

#pragma mark- 带田字格的Label
@class StrokeViewContainer,UIStrokeView;

@protocol CNFieldLabelDelegate <NSObject>
@optional
- (void)didClickOnWord:(NSString*)text;
@end

@protocol CNOneFieldLabelDelegate <NSObject>
@optional
- (void)didClickOnWord:(NSString*)text;
@end

@interface CNOneFieldLabel : UIView
@property(nonatomic,strong)UIImageView* imgv;
@property(nonatomic,strong)UIButton* btn;
@property(nonatomic,weak)UILabel* textlabel;
@property(nonatomic,weak)id<CNOneFieldLabelDelegate> delegate;
@end

typedef enum : NSUInteger{
    FieldLabelStyle_TianZiGe,
    FieldLabelStyle_Border,
}FieldLabelStyle;

@interface CNFieldLabel : UIView<CNOneFieldLabelDelegate>
{
    NSMutableArray* oneFoielLabelArr;
}

@property(nonatomic,strong)NSString* text;
@property(nonatomic,strong)UIColor* textColor;
@property(nonatomic,strong)UIFont* font;
@property(nonatomic,assign)NSUInteger cnFiedWeightHeight;
@property(nonatomic,assign)NSInteger fieldPod;//pod 从内减去
@property(nonatomic,weak)id<CNFieldLabelDelegate> delegate;
@property(nonatomic,strong)UIScrollView *scrollView;
@property(nonatomic,strong)NSString* realWords;
@property(nonatomic,assign)FieldLabelStyle fieldLabelStyle;

- (CGSize)contentSize;

- (void)changeTextStyle:(FieldLabelStyle)fieldLabelStyle;

@end

#pragma mark- 带田字格和功能按钮的View
@interface CNFieldView : UIView
{
    CGRect frameShow;
    CGRect frameUnshow;
    NSString* word;
    //
    StrokeViewContainer  *mContainer;
}
@property(nonatomic,weak,readonly)UIStrokeView *viewStroke;
@property(nonatomic,strong)NSString* word;
@property(nonatomic,assign)BOOL isShow;
- (void)playWord:(NSString*)word;
- (void)show;
- (void)unshow;
@end

#pragma mark- WordsView

@interface WordsView : UIView<CNFieldLabelDelegate,StatusButton_2_ViewDelegate,WordsDictDataDelegate,TLMutexDelegate,UIScrollViewDelegate,UIWebViewDelegate>
{
    BOOL isTransformWorking;
    //
    CGFloat lineHeight_KeyWords;
    CGFloat lineHeight_PinyinWords;
    CGFloat lineHeight_content;
    //
    StatusButton_2_View* noteBtn;
    StatusButton_2_View* biShunBtn;
    StatusButton_2_View* soundBtn;
    UISegmentedControl* langControl;
    //
    NSString* py_number;
    CNFieldLabel* lable_keyWords;
//    UILabel* lable_PinyinWords;
    UIScrollView* scrollView;
    UIWebView* _webView;
    CNFieldView* fieldView;
    UIView* functionView;
    //
    NSArray* soundArr;
    //
    NSArray* pinyinArr;
    //
    BOOL webIsLoadFinish;
}

@property(nonatomic,assign)CGPoint pt_show;
@property(nonatomic,assign)CGPoint pt_unshow;
@property(nonatomic,readonly) BOOL isInShowing;
@property(nonatomic,strong)UIView* pt_unshowFollowView;
//
@property(nonatomic,strong)NSString* bookName;
//
@property(nonatomic,assign)BOOL enBook_Dic;
//
@property(nonatomic,assign)NSInteger currentBookId;
@property(nonatomic,assign)NSInteger currentPage_C;

- (void)updateWordsWithDict:(NSDictionary *)dict forWords:(NSString *)word andPinyin:(NSString *)py_n;
- (void)addWaittingView;
- (void)clean;

- (void)setKeyWords:(NSString *)str andPy_number:(NSString*)py_n;

- (void)setSoundReady_forWords:(NSString *)word andPinyin:(NSString *)py_n;

- (void)show;
- (void)unShow;
- (void)unShow_must;

@end
